<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<title>西海良品</title>
<link rel="stylesheet" type="text/css" href="/style/rcm/css/base.css"/>
<link rel="stylesheet" type="text/css" href="/style/rcm/css/swiper.min.css"/>
<link rel="stylesheet" type="text/css" href="/style/rcm/css/xshop.css?ver=20191118"/>
<script src="/style/rcm/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/style/rcm/js/swiper.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/style/rcm/js/xShop.js?ver=2018072902" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="/style/wei/js/jquery.cookies.js"></script>
<script type="text/javascript" src="/style/new/js/jquery.lazyload.js"></script>
<script type="text/javascript" src="/style/wei/js/jquery.cookies.js"></script>      
<style> 
#nav {
    width: 80%;
    height: 40px;
    position: fixed;
    left: 20%;
    top: 4rem;
    background-color: #0066FF;
    text-align: center;
    border-radius: 50px 50px 50px 50px;
    z-index: 999999;
    display: none;
}
#nav span {
    font-size: 14px;
    color: #fff;
}
#nav img {
    display: block;
    width: 40px;
    height: 40x;
    border-radius: 100%;
    overflow: hidden;
}
.aaaa {
    margin-right: -0.2rem;
    margin-left: -0.5rem;
    margin-top: 0.4rem;
}
.list-main-left span {
    margin-bottom: 0.6rem!important;
}
.list-left-img {
    width: 1.5rem;
    height: 1.5rem;
    display: inline-block;
    float: left;
}
.list-right-word {
    float: right;
    display: inline-block;
    width: 3.2rem;
}
.list-right-word h4 {
    font-size: 0.26rem;
    color: #666;
    padding-bottom: 0.18rem;
}
.list-right-word h5 {
    color: #e5007f;
    font-size: 0.22rem;
    font-weight: bold;
    height: 0.22rem;
    line-height: 0.22rem;
    margin-bottom: 0.3rem;
    display: inline-block
}
.list-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
/*.list-main-left{ width: 80%;}*/

.list-main-left span {
    font-size: 0.22rem;
    height: 0.22rem;
    line-height: 0.22rem;
    color: #878787;
    margin-bottom: 0.06rem;
    display: inline-block
}
.list-main-left p {
    font-size: 0.22rem;
    color: #878787;
    display: flex;
    align-items: center;
}
.list-main-left p i {
    display: inline-block;
    background: url("img2.png") no-repeat;
    background-size: 100%;
    width: 0.36rem;
    height: 0.34rem;
    color: #fff;
    font-size: 0.16rem;
    text-align: center;
    line-height: 0.34rem
}
.list-main-right {
    margin-top: -0.2rem;
    display: inline-block
}
.list-main-right img {
    width: 0.42rem;
    height: 0.46rem;
    margin-bottom: 0.1rem
}
.list-main-right i {
    font-size: 0.2rem;
    font-weight: bold;
    color: #d65208;
    display: block
}
.aaaa {
    width: .58rem;
    height: .6rem;
}
.fllist li a {
    overflow: hidden;
}
/*这是新加样式开始*/
#xh_view li {
    width: 33.3%;
    float: left;
    text-align: center;
    margin-bottom: 0.2rem;
}

#xh_view li img {
    width: 1.42rem;
    margin: 0 auto 0.2rem;
    height: 1.42rem;
}

#xh_view li i {
    font-size: 0.24rem;
    color: #5f6063;
    width: 100%;
    display: block;
}
/*这是新加样式结束*/

.more {
    float: left;
    width: 100%;
    height: auto;
    padding: .2rem 0;
    background: #fff;
}
.more .zhekou, .more .sheng {
    margin-left: .2rem;
    float: left;
    width: auto;
    background: #fff;
    border: 1px solid #555;
    color: #555;
    text-align: center;
    padding: 0 .1rem;
    line-height: 24px;
    height: 24px;
    border-radius: 0 5px;
  /*  margin: 0 .2rem 0 0.2rem;*/
    font-size: .2rem;
}
.more .share {
    float: left;
    width: 2rem;
    height: .5rem;
    line-height: .5rem;
    text-align: center;
    border:1px solid #c40000;
    color: #c40000;
    font-size: .3rem;
    border-radius: 0 5px;
    margin-left: .2rem;
}
.more .warehouse {
    float: left;
    width: auto;
    margin: 0 .2rem 0 0;
}
.more .warehouse u {
    float: left;
    width: .5rem;
    text-decoration: none;
    border-radius: 0 0 0 5px;
    color: #fff;
    height: 24px;
}
.more .warehouse i {
    float: left;
    width: auto;
    background: #fff;
    border: 1px solid #666;
    color: #666;
    font-size: .25rem;
    height: 24px;
    line-height: 24px;
    padding: 0 .1rem;
    border-radius: 0 5px 0 0;
}
.more .warehouse.baoshui u {
    border: 1px solid #0080FF;
    background: url(/style/new/images/icon_warehouse.png) no-repeat #0080FF;
    background-size: .4rem .4rem;
    background-position: 2px 0;
}
.more .warehouse.baoshui i {
    border: 1px solid #0080FF;
    color: #0080FF;
}
.more .warehouse.bendi u {
    border: 1px solid #00C100;
    background: url(/style/new/images/icon_warehouse.png) no-repeat #00C100;
    background-size: .4rem .4rem;
    background-position: 2px 0;
}
.more .warehouse.bendi i {
    border: 1px solid #00C100;
    color: #00C100;
}
.more .warehouse.haiwai u {
    border: 1px solid #B200B2;
    background: url(/style/new/images/icon_warehouse.png) no-repeat #B200B2;
    background-size: .4rem .4rem;
    background-position: 2px 0;
}
.more .warehouse.haiwai i {
    border: 1px solid #B200B2;
    color: #B200B2;
}

</style>
</head>
<body>
<div class="outwrap"> 
  <!--top-->
  <div class="fl-srh-bar clearfix"> 
    <!--<a href="javascript:;" class="btn-soayisao"><i class="ico-saoyisao"></i></a>-->
    <div class="search">
      <form id="forms" action="/index/goodslist" method="get">
        <input type="text" name="keywords" class="txt" placeholder="请输入商品关键词" />
      </form>
    </div>
    <button class="btn-srh">搜索</button>
  </div>
  <div class="in-mian4 clearfix">
    <div class="sidemenu">
      <ul>
        <li data-caid="is_best"><a href="javascript:;">推&nbsp;&nbsp;荐</a></li>
          <?php
           if($this->config['cate_special_status']==1) {

               ?>
               <li data-caid="is_hot"><a href="javascript:;">特&nbsp;&nbsp;卖</a></li>
               <?php
           }
          ?>
        <?php
        if($this->category[0])
        {
          foreach($this->category[0] as $r)
          {

            if( ($r['caid']==4 && $this->user['member_level'] >0 ) || ($r['caid'] == 5 && $this->user['ximi']>0) || ($r['caid']!=4 && $r['caid']!=5 && $r['caid']!=8) || ($r['caid']==8 && $this->user['m2']==1) )
            {


              echo '<li class="big pcate" data-type="0" data-caid="'.$r['caid'].'"><a href="javascript:;" data-caid="'.$r['caid'].'">'.$r['name'].'</a></li>';
        
/*              if($this->category[$r['caid']])
              {
                  foreach($this->category[$r['caid']] as $s)
                  {
                      echo '<li class="tiny cate_'.$r['caid'].'"  style="display:none;"  data-caid="'.$s['caid'].'"><a href="javascript:;" data-caid="'.$s['caid'].'">'.$s['name'].'</a></li>';
                  }
              }*/
            }

          }
        }
        ?>        
      </ul>
    </div>
    <div class="flboxs">
      <div id="list_best" class="flbox"> 
        <!--banner-->        
        <div class="tit">
          <h2>推荐</h2>
          <em></em></div>
        <div class="ct fllist">
          <ul class="clearfix">           
          </ul>
        </div>
      </div>

        <?php
        if($this->config['cate_special_status']==1) {

            ?>
            <div id="list_hot" class="flbox">
                <div class="tit">
                    <h2>特卖</h2>
                    <em></em></div>
                <div class="ct fllist">
                    <ul class="clearfix">


                    </ul>
                </div>
            </div>

            <?php
        }
        ?>
      <div id="list_goods" class="flbox">
        <div class="tit">
          <h2>国优省特</h2>
          <em></em></div>
          <div class="ct">
              <ul class="clearfix" id="xh_view">


              </ul>
          </div>
      </div>

    </div>
  </div>
  
  <!--底部导航-->
  <div class="foot-menu">
    <ul class="clearfix">
        <li><a href="/"><i class="ico-7"></i><span>首页</span></a></li>
        <li class="on"><a href="/rcm"><i class="ico-1"></i><span>商城</span></a></li>
        <li><a href="/cart/cart"><i class="ico-5"></i><span>购物车</span></a></li>        
        <li><a href="/college"><i class="ico-8"></i><span>商学院</span></a></li>
        <li><a href="/user/index"><i class="ico-4"></i><span>我的</span></a></li>   
    </ul>
  </div>

</div>
<script type="text/javascript">

var _rcm_cookie_name = 'RCM_COOKIE',_rcm_cookie_left = 'RCM_SIDEMENU';

$(document).ready(function(e){
    
    /*清除其他页面位置COOKIE*/
    /*$.cookie("CATE_PAGE_NAME", 1 ,{ path: '/' } );
    $.cookie("CATE_PAGE_SCROLLTOP", 0 ,{ path: '/' } );*/
    $.cookie("CATE_GOODS_LIST_SCROLLTOP", 0 ,{ path: '/' } );
    $.cookie('ORDER_TYPE', '' ,{ path: '/' } );
    $.cookie('ORDER_PAGE', '' ,{ path: '/' } );

/*    $(".pcate").click(function(){

        var cid = $(this).attr("data-caid");
        var t = $(this).attr("data-type");
        if(t==0){

            $(this).attr("data-type",1);
            $(".cate_"+cid).show();

        }else{
            $(this).attr("data-type",0);
            $(".cate_"+cid).hide();

        }

    })*/
    /*搜索*/
    $(".btn-srh").bind("click",function(){
      if( $("#forms input").prop("val" +
          "ue")!="" )
      {
        $("#forms").submit();
      }
    });

    var _ckstr = $.cookie(_rcm_cookie_name);


    if(_ckstr!=null && _ckstr!="" )
    {
      // console.log(_ckstr);
      var ar = _ckstr.split("|");
      // console.log(ar);
      _getGoods(ar[0],ar[1],ar[2]);
    }
    else
    {
      _getGoods('is_hot',1);
    }

    var _csstr = $.cookie(_rcm_cookie_left);
    if(_csstr!=null && _csstr!="")
    {
      $(".sidemenu").scrollTop(_csstr);
    }
    $(".in-mian4").scroll(function(){

      _saveCookie();

      // console.log( $(".in-mian4").height() +' - '+ $(".flboxs").height() + ' - ' + $(".in-mian4").scrollTop());

      if(_g_caid!="" && !_ajax && _g_page < _g_maxpage)
      {
        if( $(".flboxs").height() - $(".in-mian4").height() - $(".in-mian4").scrollTop() < 200  )
        {
          _getGoods(_g_caid,_g_page + 1);
        }
      }

    });

    $(".sidemenu").scroll(function(){
      // console.log( $(".sidemenu").scrollTop());
      $.cookie(_rcm_cookie_left, $(".sidemenu").scrollTop() ,{ path: '/' } );
    });
});


function _saveCookie()
{
  var _cstr = _g_caid +"|"+_g_page+"|"+$(".in-mian4").scrollTop();
  $.cookie(_rcm_cookie_name, _cstr ,{ path: '/' } );
}



$.cookie("CAID", <?=$_GET['caid']?:0?> ,{ path: '/' } );
var _g_caid = '',_g_page = 1,_g_maxpage = 1,_ajax = false;
var _config = <?=$this->config['cate_special_status']==1 ?1:0?>;
var cid = <?=$_GET['caid']?:0?>;
if(cid >0){
    _g_caid = cid;
    _saveCookie();
}
function _getGoods(caid,page,pos)
{

  if(typeof pos =="undefined")
  {
    pos = -1;
  }
if($.cookie("CAID")>0){
    caid = $.cookie("CAID");
    $.cookie("CAID", 0 ,{ path: '/' } );

}

  // _ajax = true;
  _g_caid = caid;
  _g_page = page;

    var type=0;
    var act="getlist";
  if(pos == -1)
  {
    _saveCookie();
  }

  var _obj = "list_goods";
  if(caid == "is_best")
  {
    _obj = "list_best";
  }
  else if(caid == "is_hot" && _config ==1)
  {

    _obj = "list_hot";
  }

  if(page==1 || pos>=0)
  {
    
      $(".flbox").css("display","none");
      $(".sidemenu ul li").removeClass("avtive");
      if(caid=="is_best")
      {
        $("#list_best").css("display","block");
        $(".sidemenu ul li:eq(0)").addClass("avtive");
      }
      else if(caid=="is_hot")
      {
        $("#list_hot").css("display","block");
        $(".sidemenu ul li:eq(1)").addClass("avtive");
      }
      else
      {

          type = 1;
        $("#list_goods").css("display","block");

        $(".sidemenu ul li").each(function(){
          var _caid = $(this).attr("data-caid");
          if(_caid == caid)
          {
            $(this).addClass('avtive');
            $("#list_goods h2").html( $(this).find("a").html() );
          }
        });

        
      }
    
      
    if(pos<0)
    {
      $("#"+_obj+" .ct ul").empty();
    }
  }

 if(type==1){

     act = "getCateSon";
 }
  $.post("/rcm/ajax",
  {
    "act":act,
    "caid":caid,
    "page":page,
    "pos":pos,
  },function(json){
    _ajax = false;

     console.log(json.data);
    if(json.count > 0)
    {
      _g_maxpage = json.maxpage;
      _g_page = json.page;

      var _html = '';
      $.each(json.data,function(i,v){

    	   if(type>0){

               var _cover = '/style/new/images/lazyload_cover.gif';
               if(v.pic!="" && v.docid >0)
               {
                   _cover = v.pic;
               }

               _html +='<li><a href="/index/goodslist?caid='+v.caid+'"><img src="/style/new/images/lazyload_cover.gif" class="lazyimg" data-original="'+_cover+'" /><i>'+v.name+'</i></a></li>';

       
        }else{

    	     var _cover = '/style/new/images/lazyload_cover.gif';
    	     var sale = "";
             /*  sale = '<span class="yx fl">已销'+v.sales_count+'笔</span> <span class="kc fr">库存'+v.goods_number+'件</span>';*/

          if(v.thumb_docid!="" && v.thumb_docid!="0")
          {
            _cover = v.thumb_docid;
          }

          var _more = '',_price = '',zhekou="",sheng="";

          if(v.shop_price>0)
          {
            _price = '￥'+v.shop_price;
          }else if(v.ximi_price>0)
          {
            _price = v.ximi_price * 1 + '硒米';
          }

          if(v.price_me >0 || v.coupon_price > 0)
          {


           /* if(v.price_me > 0)
            {
                _more += '<div class="zhekou">返'+(v.price_me * 1)+'</div>';
            }

            if(v.coupon_price > 0)
            {
                _more += '<div class="sheng">抵券'+v.coupon_price+'</div>';
            }*/
          }



          
  
          _html += '<li><a href="/index/goodsdetail?goods_id='+v.goods_id+'" class="clearfix">              <div class="img"><img src="/style/new/images/lazyload_cover.gif" class="lazyimg" data-original="'+_cover+'" /></div>              <div class="word">                <p>'+v.goods_name+'</p>                                <div class="yxkc clearfix"> '+sale+' </div>                <div class="prc clearfix" style="display: flex;align-items: center;font-size: 0.26rem;"> <span class="price fl">'+_price+'</span> <div class="more">  '+_more+'</div></div></div></a></li>';

        }
      });
      $("#"+_obj+" .ct ul").append(_html);

      if(pos>0)
      {
          // alert(pos)
        $(".in-mian4").scrollTop(pos);
      }

      $(".lazyimg").lazyload({
        container:".in-mian4",  
        threshold : 150,
        placeholder : "/style/new/images/lazyload_cover.gif",
        failurelimit : 4
      });
    }
  },"json");
}
</script>
<?php
if($this->JSAPI){
?>
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script>
wx.config({
  appId: '<?=$this->JSAPI['appId'];?>',
  timestamp: '<?=$this->JSAPI['timestamp'];?>',
  nonceStr: '<?=$this->JSAPI['nonceStr'];?>',
  signature: '<?=$this->JSAPI['signature'];?>',
  jsApiList: [
    'onMenuShareTimeline', //分享到朋友圈
    'onMenuShareAppMessage' //分享给朋友
  ]
});
wx.checkJsApi({
    jsApiList: ['onMenuShareTimeline','onMenuShareAppMessage'], // 需要检测的JS接口列表，所有JS接口列表见附录2,
    success: function(res) {
    // 以键值对的形式返回，可用的api值true，不可用为false
    // 如：{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
    // alert(res);
    }
});
wx.ready(function () {
  wx.onMenuShareAppMessage({
    title: '西海良品',
    desc: '',
    link: '<?=$this->JSAPI['url'];?>',
    imgUrl: 'https://<?=$_SERVER['HTTP_HOST'];?>/style/wei/images/tuijian/tj_logo_big2.jpg',
    type: 'link',
    dataUrl: '',
    success: function () {
    // 用户确认分享后执行的回调函数
    },
    cancel: function () {
    // 用户取消分享后执行的回调函数
    }
  });
  
    // 分享到朋友圈
    wx.onMenuShareTimeline({
      title: '西海良品', // 分享标题
      link: '<?=$this->JSAPI['url'];?>',
      imgUrl: 'https://<?=$_SERVER['HTTP_HOST'];?>/style/wei/images/tuijian/tj_logo_big2.jpg',
      success: function () {
      // 用户确认分享后执行的回调函数
    },
    cancel: function () {
      // 用户取消分享后执行的回调函数
      }
  });  

});
</script>
<?
}
?>
</body>
</html>